<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="oa.entity.Attendance"%>
<%@page import="oa.service.impl.AttendanceServiceImpl"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@  taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">


<%@ include file="common/head.jsp"%>

<body class="fix-header fix-sidebar">
    
    <!-- Preloader - style you can find in spinners.css -->
	<div class="preloader">
		<svg class="circular" viewBox="25 25 50 50">
				<circle class="path" cx="50" cy="50" r="20" fill="none"
				stroke-width="2" stroke-miterlimit="10" /> </svg>
	</div>
	<!-- Main wrapper  -->
	<div id="main-wrapper">
		<!-- header header  -->
		<%@ include file="common/header.jsp"%>
		<!-- End header header -->
		<!-- Left Sidebar  -->
		<%@ include file="common/nav.jsp"%>
		<!-- End Left Sidebar  -->
		<!-- Page wrapper  -->
		<div class="page-wrapper">
			<!-- 锐高软件 -->
	    <%@ include file="../common/ruigao.jsp" %>
				
			
				
				<div class="container-fluid">
				<!-- Bread crumb -->
              
				<div class="row">
					<div class="col-md-3">
						<div class="card p-30">
							<div class="media">
								<div class="media-left meida media-middle">
									<span><i class="fa fa-user f-s-40 color-primary"></i></span>
								</div>
								<div class="media-body media-text-right">
									<h2>${userCount}</h2>
									<p class="m-b-0">总人数</p>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-3">
						<div class="card p-30">
							<div class="media">
								<div class="media-left meida media-middle">
									<span><i class="fa fa-user f-s-40 color-danger"></i></span>
								</div>
								<div class="media-body media-text-right">
									<h2>${userCounts}</h2>
									<p class="m-b-0">今日签到人数</p>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-3">
						<div class="card p-30">
							<div class="media">
								<div class="media-left meida media-middle">
									<span><i
										class="fa fa-shopping-cart f-s-40 color-success"></i></span>
								</div>
								<div class="media-body media-text-right">
									<h2>待定</h2>
									<p class="m-b-0">待定</p>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-3">
						<div class="card p-30">
							<div class="media">
								<div class="media-left meida media-middle">
									<span><i class="fa fa-archive f-s-40 color-warning"></i></span>
								</div>
								<div class="media-body media-text-right">
									<h2>待定</h2>
									<p class="m-b-0">待定</p>
								</div>
							</div>
						</div>
					</div>
				</div>
		   

			  <!--
                	作者：offline
                	时间：2018-03-28、
                	描述：two板块
               -->
				<div class="row">
					<div class="col-lg-12">
						<div class="card">
							<div class="card-title">
								<h4>通知</h4>
							</div>
							<div class="recent-comment">
								<c:forEach var="mess" items="${PageInfo.getPageList() }" >
								<div class="media">
									<div class="media-left">
										<a ><img alt="可爱" src="images1/1.png"
											class="media-object"></a>
									</div>
									<div class="media-body">
										<h4 class="media-heading">${mess.messageTypes}</h4>
										<p>${mess.messageContent}</p>
										<p class="comment-date"><fmt:formatDate  type="both" value="${mess.messageTimes}" pattern="yyyy-MM-dd" /></p>
									</div>
									
									<button type="button"
											class="btn btn-success btn-sm btn-rounded m-b-2 m-l-5">
									<a href="${pageContext.request.contextPath}/messageservice?rid=${mess.messageId}&opt=selectuser"
											style="color: white;">查看通知</a>
									</button>
					
									
									
								</div>
								</c:forEach>
								<!--上一页--下一页-->
									<div class="table-responsive m-t-40">
										<div id="example23_wrapper" class="dataTables_wrapper">
											<div class="dataTables_paginate paging_simple_numbers"
												id="example23_paginate" id="pageshow">

												<a href="indexServlet?PageNo=1" class="paginate_button"
													aria-controls="example23" data-dt-idx="7" tabindex="0"
													id="example23"> <font style="vertical-align: inherit;">
														<font style="vertical-align: inherit;"></font>首页
												</font>
												</a>
												<c:if test="${PageInfo.getHasPrevPage() }">
													<a
														href="indexServlet?PageNo=${PageInfo.getPrevPage() }&opt=selectpartuser"
														class="paginate_button previous disabled"
														aria-controls="example23" data-dt-idx="0" tabindex="0"
														id="example23_previous"><font
														style="vertical-align: inherit;"><font
															style="vertical-align: inherit;">上一页</font></font> <input
														type="hidden" id="departid" name="DeparTid" value="">

													</a>
												</c:if>
												<span> 
												<c:forEach items="${PageInfo.getGroupPage()}"
														var="pageI">
														<a href="indexServlet?PageNo=${pageI}" class="paginate_button"
															aria-controls="example23" data-dt-idx="7" tabindex="0"
															id="example23"> <font
															style="vertical-align: inherit;"> <font
																style="vertical-align: inherit;">${pageI }</font></font>
														</a>
													</c:forEach>
												</span>

												<c:if test="${PageInfo.getHasNextPage() }">
													<a
														href="indexServlet?PageNo=${PageInfo.getNextPage()}&opt=selectpartuser"
														class="paginate_button next" aria-controls="example23"
														data-dt-idx="7" tabindex="0" id="example23_next"><font
														style="vertical-align: inherit;"><font
															style="vertical-align: inherit;">下一页</font></font> <input
														type="hidden" id="departidd" name="DeparTid" value="">
													</a>
												</c:if>
												<a href="indexServlet?PageNo=${PageInfo.getTotalPage()}"
													class="paginate_button" aria-controls="example23"
													data-dt-idx="7" tabindex="0" id="example23"> <font
													style="vertical-align: inherit;"> <font
														style="vertical-align: inherit;"></font>末页
												</font>
												</a>
											</div>
										</div>
									</div>		     
								    <!-- 获取到当前登陆的员工id -->
									<input type="hidden" name="opt" id="opt" value="">
									<input type="hidden" name="userid" id="userid" value="${userid}">
							      
							</div>
						</div>
						<!-- /# card -->
					</div>

				</div>

			</div>
		</div>

	</div>
	<!-- footer -->
	<%@ include file="common/footer.jsp"%>
	<!-- End footer -->
	<%@ include file="common/js.jsp"%>
	<script type="text/javascript">
	$(function(){
		//点击签到将ID传到servlet里
		$(".qiandao").click(function(){
			//判断是否签到
				$("#opt").val("qiandao");
				var id = parseInt($("#userid").val());
				var opt = $("#opt").val();
				$.ajax({
					url:"showattendance",
					data:{"opt":opt,"userid":id},
					type:"GET",
					dataType:"JSON",
					success:function(data){					
						if(data.Verify==true){
							if(data.bool==true){
								swal({
									title : '签到成功！',
									type : 'success',
									confirmButtonText : '确定',
									closeOnConfirm : false
								});
								}
						}else if(data.bool==false){
							swal({
								title : '今天已签到,不能重复操作！',
								type : 'error',
								confirmButtonText : '确定',
								closeOnConfirm : false
							});
						}else if(data.Verify==false){
							swal({
								title : '很抱歉,现在不是签到时间!',
								type : 'error',
								confirmButtonText : '确定',
								closeOnConfirm : false
							});
						}
						
					},error:function(data){
						swal({
							title : '签到失败！',
							type : 'error',
							confirmButtonText : '确定',
							closeOnConfirm : false
						});
					}
					
				});
			
		});
		
		
		
		//点击签退将ID传到servlet里
		$(".qiantui").click(function(){
			$("#opt").val("qiantui");
			var userid=parseInt($("#userid").val());
			var opt = $("#opt").val();
			$.ajax({
				url:"showattendance",
				data:{"opt":opt,"userid":userid},
				type:"GET",
				dataType:"JSON",
				success:function(data){	
					if(data.Verify==true){
						if(data.bool==true){
							swal({
							title : '签退成功！',
							type : 'success',
							confirmButtonText : '确定',
							closeOnConfirm : false
						});
					}
					}else if(data.bool==false){
						swal({
							title : '今天已签退,不能重复操作!',
							type : 'error',
							confirmButtonText : '确定',
							closeOnConfirm : false
						});
					}else if(data.Verify==false){
						swal({
							title : '很抱歉,现在不是签退时间!',
							type : 'error',
							confirmButtonText : '确定',
							closeOnConfirm : false
						});
					}
					
					
				},error:function(data){
					swal({
				        title : '签退失败！',
						type : 'error',
						confirmButtonText : '确定',
						closeOnConfirm : false
					});
				}
				
			});
			
		});
		
	
		
		function currenttime() {
			var today = new Date();
			var yy = today.getYear();
			var $MM = today.getMonth();
			var dd = today.getDay();
			var hh = today.getHours();
			var mm = today.getMinutes();
			var ss = today.getSeconds();
			if (hh < 10) {
				hh = "0" + hh;
			}
			if (mm < 10) {
				mm = "0" + mm;
			}
			if (ss < 10) {
				ss = "0" + ss;
			}
			document.getElementById("current-time").innerHTML = hh + ":" + mm + ":"
					+ ss;
		}
		setInterval("currenttime()", 1000);
	
	});
	
	
	</script>

</body>